/**
 * All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
 * <p>
 * PmRiskResponsesService
 * 风险应对
 * <p>
 * 修改纪录
 * 2020-05-13 版本：1.0 wushenghong 创建。
 *
 * @version 版本：1.0
 * @author 作者：wushenghong
 * 创建日期：2020-05-13
 */
package com.topscomm.pm.service.impl;

import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;
import com.topscomm.pm.pojo.PmRiskResponsesEntity;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.pm.service.IPmRiskResponsesService;
import com.topscomm.pm.service.impl.auto.PmRiskResponsesServiceAuto;

@Service(value = "pmRiskResponsesService")
@Scope(value = "singleton")
public class PmRiskResponsesService extends PmRiskResponsesServiceAuto implements IPmRiskResponsesService {
    /**
     * @param entity
     * @throws ServiceException
     * @author: wushenghong
     * @date: 2020-05-12
     * @description:单号生成
     * @modify:
     */
    @Override
    protected void beforeInsert(BasicEntity entity) {
        super.beforeInsert(entity);
        if (entity.getId() <= 0) {// 赋值Id和单号
            long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
            entity.setId(arrayId[0]);
            String docNo = String.valueOf(arrayId[0]);
            docNo = docNo.substring(0, 6) + docNo.substring(9);
            entity.setValue(PmRiskResponsesEntity.FieldDocno, docNo);
        }
    }
}
